Skip to content

Add run_constrained support to grayskull dependency updates#5646

Open
ctcjab wants to merge 4 commits intoregro:mainfrom
chicagotrading:add-run-constrained-support
Open

Add run_constrained support to grayskull dependency updates#5646
ctcjab wants to merge 4 commits intoregro:mainfrom
chicagotrading:add-run-constrained-support

Conversation

@ctcjab
Copy link

@ctcjab ctcjab commented Feb 27, 2026

Description:

The update-grayskull inspection feature now updates run_constrained dependencies when bumping package versions. This prevents stale version constraints that can break downstream packages.

Changes:

  • Add "run_constrained" to SECTIONS_TO_PARSE
  • Add new SECTIONS_TO_UPDATE_CONSTRAINTS_ONLY constant for conservative updates
  • Add constraints_only parameter to _apply_env_dep_comparison()
  • Update _apply_dep_update_v1() and apply_dep_update() to handle run_constrained
  • Update generate_dep_hint() to show run_constrained updates

The constraints-only behavior for run_constrained:

  • ✅ Updates version constraints for packages in both recipe and grayskull
  • ❌ Does NOT add new packages (optional deps are maintainer's choice)
  • ❌ Does NOT remove packages (maintainer may have specific reasons)

This conservative approach fixes stale constraints while respecting maintainer decisions about which optional dependencies to include.

Checklist:

  • Pydantic model updated or no update needed

Cross-refs, links to issues, etc:

Fixes #5645

Real-world example: litellm-feedstock had stale uvicorn constraint >=0.31.1,<0.32.0 instead of upstream's >=0.32.1,<1.0.0, breaking packages like notebook_intelligence.

The update-grayskull inspection feature now updates run_constrained
dependencies when bumping package versions. This prevents stale version
constraints that can break downstream packages.

Changes:
- Add "run_constrained" to SECTIONS_TO_PARSE
- Add new SECTIONS_TO_UPDATE_CONSTRAINTS_ONLY for conservative updates
- Add constraints_only parameter to _apply_env_dep_comparison()
- Update _apply_dep_update_v1() and apply_dep_update() to handle
  run_constrained with constraints-only behavior
- Update generate_dep_hint() to show run_constrained updates

The constraints-only behavior for run_constrained:
- Updates version constraints for packages in both recipe and grayskull
- Does NOT add new packages (optional deps are maintainer's choice)
- Does NOT remove packages (maintainer may have specific reasons)

This fixes issues like litellm-feedstock where uvicorn constraint was
stale (>=0.31.1,<0.32.0) instead of upstream's (>=0.32.1,<1.0.0).

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Copy link
Contributor

@beckermr beckermr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR needs testing against v1 recipes. Those recipes put run constraints in a different part of the recipe.

@ctcjab
Copy link
Author

ctcjab commented Mar 2, 2026

@beckermr thanks for the quick review! Since I am not sure when I'll have time to pick this back up, anyone reading this please feel free to take over here. Happy to grant anyone permission to push to my branch as needed.

@beckermr
Copy link
Contributor

beckermr commented Mar 2, 2026

OK. happy to wait on this PR until you have time.

@ctcjab
Copy link
Author

ctcjab commented Mar 7, 2026

This PR needs testing against v1 recipes. Those recipes put run constraints in a different part of the recipe.

Added a test for a v1 recipe in ce05015.

But based on https://conda.org/learn/ceps/cep-0014/#requirements-section and https://docs.conda.io/projects/conda-build/en/latest/resources/define-metadata.html#run-constrained both v1 and v0 recipes use the same location, requirements.run_constrained. Let me know if I'm missing something, and thanks again for the quick review.

@beckermr
Copy link
Contributor

beckermr commented Mar 9, 2026

It is called for v0 (conda-build)

requirements:
  run_constrained:
    - optional-subpackage =={{ version }}

and for v1 (rattler-build)

requirements:
  run_constraints:
    - optional-subpackage =={{ version }}

See https://github.com/prefix-dev/recipe-format/blob/c33fce275c3d721a892abf95ef1c43bd6f96012c/examples/valid/single-output/recipe.yaml#L115

Notice it is run_constrained vs run_constraints.

v0 recipes (conda-build) use "run_constrained" while v1 recipes
(rattler-build) use "run_constraints". Update _apply_dep_update_v1()
to look for the correct section name when processing v1 recipes.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@ctcjab
Copy link
Author

ctcjab commented Mar 10, 2026

Oops, thanks for catching that! Fixed in 034de92:

  • Updated _apply_dep_update_v1() to look for run_constraints in v1 recipes
  • Updated the test to use the correct v1 section name

The internal dep_comparison dict still uses run_constrained as the key for consistency, but when applying to v1 recipes the code now correctly maps it to run_constraints.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

update-grayskull does not update run_constrained version constraints

2 participants